package com.inhim.pjhim.adapter;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.inhim.pjhim.R;
import com.inhim.pjhim.entity.ReaderTagList;

import org.yczbj.ycrefreshviewlib.adapter.RecyclerArrayAdapter;
import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;


public class SearchTagAdapter extends RecyclerArrayAdapter<ReaderTagList.List> {

    private Activity context;
    PersonViewHolder viewHolder;

    public SearchTagAdapter(Activity context) {
        super(context);
        this.context=context;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        View mView = null;
        if (mView == null) {
            mView = LayoutInflater.from(context).inflate(R.layout.item_search_tag, null);
            viewHolder = new PersonViewHolder(mView);
        } else {
            viewHolder = (PersonViewHolder) mView.getTag();
        }
        return viewHolder;
    }

    public class PersonViewHolder extends BaseViewHolder<ReaderTagList.List> {
        public TextView tv_lable;

        public PersonViewHolder(View itemView) {
            super(itemView);
            tv_lable = getView(R.id.tv_lable);
        }

        @Override
        public void setData(ReaderTagList.List data) {
            super.setData(data);
            if(data.getName()==null || "".equals(data.getName())){
                tv_lable.setVisibility(View.GONE);
            }else{
                tv_lable.setVisibility(View.VISIBLE);
                tv_lable.setText(data.getName());
            }
           /* if(viewHolder!=null){
                viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent=new Intent(context, TypeListActivity.class);
                        intent.putExtra("TAG","ReadingTwoFragment");
                        intent.putExtra("ReaderTypeList", (Serializable) getAllData());
                        intent.putExtra("position",getAdapterPosition());
                        context.startActivity(intent);
                    }
                });
            }*/
        }

    }

}
